class ExpandSongsTable < ActiveRecord::Migration
  def self.up
    change_table :songs do |t|
      t.integer :track
      t.integer :disc
      t.integer :length
      t.integer :edition_id
    end

    create_table :song_versions do |t|
      t.integer :song1_id
      t.integer :song2_id
    end

    add_foreign_key(:song_versions, :songs, :column => :song1_id)
    add_foreign_key(:song_versions, :songs, :column => :song2_id)
    add_foreign_key(:songs, :editions, :column => :edition_id)
  end

  def self.down
    change_Table :songs do |t|
      t.remove :track
      t.remove :disc
      t.remove :length
      t.remove :edition_id
    end

    drop_table :song_versions

    remove_foreign_key(:song_versions, :column => :song1_id)
    remove_foreign_key(:song_versions, :column => :song2_id)
    remove_foreign_key(:songs, :column => :edition_id)
  end
end
